// JavaScript Document
$(document).ready(function(e) {
    $(window).load(function(){
		
$('.enrollMain .title span').click(function(){

	$('.enrollMain .title span').removeClass('active');
	$(this).addClass('active');
	var num=$('.enrollMain .title span').index($(this))
	$('.enrollForm1').removeClass('none')
	$('.enrollForm1').eq(Math.abs(num-1)).addClass('none')
	})



//------------form表单切换--------------------------------

$('#enrollPhoneTxt').blur(function(){
	
	var str=$('#enrollPhoneTxt').val();
	var test=/^1[3|5|8]\d{9}$/.test(str);
	if(!test){
		$('.enrollForm1>.p1').html('请输入正确的手机号码')
		}else{$('.enrollForm1>.p1').html('')}
	
	})
//----------手机号码验证-------------------------------	
$('#enrollPhonePwd1').focus(function(){
		$('.enrollForm1>.p2').html('<span class="span1">弱</span><span class="span2">中</span><span class="span3">强</span>');
		this.timer=setInterval(main,200)
		function main(){
			var str=$('#enrollPhonePwd1').val();
			
			if(str.length<10){
				$('.enrollForm1>.p2 span').css('border',0);
				$('.enrollForm1>.p2 .span1').css('border-bottom','1px solid #F00')
			}
			if(str.length>=10&&str.length<20){
				$('.enrollForm1>.p2 span').css('border',0);
				$('.enrollForm1>.p2 .span2').css('border-bottom','1px solid #F00')
			}
			if(str.length>=20){
				$('.enrollForm1>.p2 span').css('border',0);
				$('.enrollForm1>.p2 .span3').css('border-bottom','1px solid #F00')
			}
		}
	})
$('#enrollPhonePwd1').blur(function(){
	clearInterval(this.timer)
	var str=$('#enrollPhonePwd1').val();
	var test=/^.{6,}$/.test(str);
	if(!test){
		$('.enrollForm1>.p2').html('请输入正确格式的密码');
		}else{$('.enrollForm1>.p2').html('')}
	
	})
	
$('#enrollPhonePwd2').blur(function(){
	
	var str=$('#enrollPhonePwd1').val();
	var str2=$('#enrollPhonePwd2').val();
	
	if(str!=str2){
		$('.enrollForm1>.p3').html('您输入的密码不正确');
		}else{$('.enrollForm1>.p3').html('')}
	
	})
//---------确认密码部分-----------------------------------

$('.enrollForm1>a').eq(0).click(function(){
	var chk = document.getElementById('enrollCheckbox1');
	var str1=$('.enrollForm1>.p1').html()
	var str2=$('.enrollForm1>.p2').html()
	var str3=$('.enrollForm1>.p3').html()
	var str4=$('#enrollPhoneTxt').val();
	//alert(typeof str4)
	var str5=$('#enrollPhonePwd1').val();
	var str6=$('#enrollPhonePwd2').val();
	if(str4.length==0||str5.length==0||str6.length==0){
		alert('必填项不能为空');
		return false
		}
	if(str1==str2&&str1==str3&&chk.checked){
		setCookie(str4,str5,10);
		alert('注册成功');
		window.open('load.html','开始登录')
		return true;
		}
	return false;
	

	})
//---------------以上为手机号注册部分--------------------------------------



$('#enrollEmailTxt').blur(function(){
	var str=$('#enrollEmailTxt').val();
	var test=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(str);
	if(!test){
		$('.enrollForm1>.p1').html('请输入正确的邮箱号码')
		}else{$('.enrollForm1>.p1').html('')}
	

	})

$('#enrollEmailPwd1').focus(function(){
		$('.enrollForm1>.p2').html('<span class="span1">弱</span><span class="span2">中</span><span class="span3">强</span>');
		this.timer=setInterval(main,200)
		function main(){
			var str=$('#enrollEmailPwd1').val();
			
			if(str.length<10){
				$('.enrollForm1>.p2 span').css('border',0);
				$('.enrollForm1>.p2 .span1').css('border-bottom','1px solid #F00')
			}
			if(str.length>=10&&str.length<20){
				$('.enrollForm1>.p2 span').css('border',0);
				$('.enrollForm1>.p2 .span2').css('border-bottom','1px solid #F00')
			}
			if(str.length>=20){
				$('.enrollForm1>.p2 span').css('border',0);
				$('.enrollForm1>.p2 .span3').css('border-bottom','1px solid #F00')
			}
		}
	})
$('#enrollEmailPwd1').blur(function(){
	clearInterval(this.timer)
	var str=$('#enrollEmailPwd1').val();
	var test=/^.{6,}$/.test(str);
	if(!test){
		$('.enrollForm1>.p2').html('请输入正确格式的密码');
		}else{$('.enrollForm1>.p2').html('')}
	
	})
	
$('#enrollEmailPwd2').blur(function(){
	
	var str=$('#enrollEmailPwd1').val();
	var str2=$('#enrollEmailPwd2').val();
	
	if(str!=str2){
		$('.enrollForm1>.p3').html('您输入的密码不正确');
		}else{$('.enrollForm1>.p3').html('')}
	
	})

$('.enrollForm1>a').eq(1).click(function(){
	
	var chk = document.getElementById('enrollCheckbox2');
	var str1=$('.enrollForm1>.p1').html()
	var str2=$('.enrollForm1>.p2').html()
	var str3=$('.enrollForm1>.p3').html()
	var str4=$('#enrollEmailTxt').val();
	var str5=$('#enrollEmailPwd1').val();
	var str6=$('#enrollEmailPwd2').val();
	if(str4.length==0||str5.length==0||str6.length==0){
		alert('必填项不能为空');
		return false
		}
	if(str1==str2&&str1==str3&&chk.checked){
		setCookie(str4,str5,10);
		alert('注册成功');
		window.open('load.html','开始登录')
	
		
		
		
		
		
		return true;
		}
	return false;
	

	})
















		
//-------------表单验证-----------------------------		
		
$('.load .p4').click(function(){
	var name=$('#loadName').val();
	var pwd=$('#loadPaw').val();
	if(pwd==getCookie(name)){
		alert('登录成功');
		setCookie('zidong',name,1);
		
		window.open('../index.html','聚惠买首页');
		
		
		}
	else{
		alert('请输入正确的密码')
		}
	})		
	



		
//-------------谷歌cookie不能用----------------------------		
		
		
		
		
		
		
//--------------以上为登录页代码---------------------------------------------------		
		
		
		
		
	
		
		
		
		})
});




















































